package com.notary.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.notary.entity.vo.JsonResult;
import freemarker.template.utility.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import  com.notary.service.NotaryOrgService;
import com.notary.entity.NotaryOrg;

/**
* <p>
* 机构表 前端控制器
* </p>
* @author xujun
* @since 2020-09-07
*/


@Api(tags = "机构表控制器")
@RequestMapping("/notaryOrg")
@RestController
public class NotaryOrgController{


    NotaryOrgService notaryOrgService;

    @Autowired
    public  NotaryOrgController(NotaryOrgService notaryOrgService){
        this.notaryOrgService = notaryOrgService;
    }

    /**
    * <p>
        * 根据条件查询全部记录（并翻页）
        * </p>
    */

    @ApiOperation(value = "列表查询")
    @PostMapping("/list")
    public JsonResult<IPage<NotaryOrg>> list(int pageNum,int pageSize, @RequestBody NotaryOrg notaryOrg) {
        Page<NotaryOrg> page = new Page<NotaryOrg>(pageNum,pageSize);
        QueryWrapper<NotaryOrg> queryWrapper= new QueryWrapper<>();
        if(!StringUtils.isEmpty(notaryOrg.getOrgNo())){
            queryWrapper.like("notary_no",notaryOrg.getOrgNo());
        }
        if(!StringUtils.isEmpty(notaryOrg.getOrgName())){
            queryWrapper.like("notary_name",notaryOrg.getOrgName());
        }
        IPage<NotaryOrg> iPage = notaryOrgService.page(page,queryWrapper);
        return JsonResult.success(iPage);
    }


}

                       